package org.easymodelers.gmf.update;

import org.easymodelers.expression.ExpressionData;
import org.easymodelers.template.utils.DynamicModelManager;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;

public abstract class AbstractGenModelUpdate {

	protected EList<EObject> getEObjectsForExpression(
					GenEditorGenerator rootEObject, ExpressionData expressionData) {
		if (expressionData.getConditionFieldName()!=null
					&& expressionData.getConditionFieldValue()!=null) {
			return DynamicModelManager.findEObjects(rootEObject, expressionData.getType(),
												expressionData.getConditionFieldName(),
												expressionData.getConditionFieldValue(), false);
		} else {
			return DynamicModelManager.findEObjects(rootEObject, expressionData.getType(), false);
		}
	}
}
